// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.asm;

import java.util.Set;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class UnusedLabelsRemover extends MethodAdapter {

  private final Set<Label> usedLabels;

  public UnusedLabelsRemover(MethodVisitor out, Set<Label> usedLabels) {
    super(out);
    this.usedLabels = usedLabels;
  }
  
  @Override
  public void visitLabel(Label label) {
    if (usedLabels.contains(label)) {
      super.visitLabel(label);
    }
  }
}
